/**
 * Copyright (c) Software Institude of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.uml.Fragments;
// imports:
import org.w3c.dom.Element;

import edu.pku.sei.gefcommon.descriptor.annotation.EnumerationProperty;
import edu.pku.sei.gefcommon.descriptor.annotation.MethodProperty;
import edu.pku.sei.modeler.model.common.MetaTypedList;
import edu.pku.sei.modeler.model.uml.BasicInteractions.InteractionFragment;
import edu.pku.sei.modeler.model.xml.XMLUtility;
import edu.pku.sei.modeler.uml.modelHelper.ModelPackage;

/**
 * @generated
 *
 */
public class CombinedFragment extends InteractionFragment implements ICombinedFragment {
	// attributes
	
	protected InteractionOperator interactionOperator = InteractionOperator.SEQ;
	
	
	
	
	// references
	
	protected MetaTypedList operand;
	
	protected MetaTypedList cfragmentGate;
	
	protected MetaTypedList fragment;
	
	// getters & setters for attributes
	@MethodProperty(
			id = "COMBINEDFRAGMENT_INTERACTIONOPERATOR", 
			catalog = "Model", 
			name = ModelPackage.COMBINEDFRAGMENT_INTERACTIONOPERATOR, 
			setter = "setInteractionOperator")
	@EnumerationProperty(function = "getAllOperatorKinds")
	public InteractionOperator getInteractionOperator() {
		return interactionOperator;
	}
	public void setInteractionOperator(InteractionOperator newInteractionOperator) {
		InteractionOperator oldinteractionOperator = interactionOperator;
		interactionOperator = newInteractionOperator;
		firePropertyChange(ModelPackage.COMBINEDFRAGMENT_INTERACTIONOPERATOR, oldinteractionOperator, newInteractionOperator);
	}
	public Object[] getAllOperatorKinds() {
		return InteractionOperator.getAllOperatorKinds();
	}
	// getters for references
	
	public MetaTypedList getOperand() {
		if(operand == null) {
			operand = new MetaTypedList(InteractionOperand.class, this, ModelPackage.COMBINEDFRAGMENT_OPERAND);
		}
		return operand;
	}
	
	public MetaTypedList getCfragmentGate() {
		if(cfragmentGate == null) {
			cfragmentGate = new MetaTypedList(Gate.class, this, ModelPackage.COMBINEDFRAGMENT_CFRAGMENTGATE);
		}
		return cfragmentGate;
	}
	
	public MetaTypedList getFragment() {
		if(fragment == null) {
			fragment = new MetaTypedList(InteractionFragment.class, this, ModelPackage.INTERACTION_FRAGMENT);
		}
		return fragment;
	}
	
	// save & load
	public void serialize(Element root) {
		super.serialize(root);
		// attributes
		
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.COMBINEDFRAGMENT_INTERACTIONOPERATOR, 
				interactionOperator.getValue());
		
		// references
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.COMBINEDFRAGMENT_OPERAND, operand);
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.COMBINEDFRAGMENT_CFRAGMENTGATE, cfragmentGate);
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.INTERACTION_FRAGMENT, fragment);
		
	}
	
	public void deSerialize(Element root) {
		super.deSerialize(root);
		// attributes
		
		setInteractionOperator(new InteractionOperator(
				XMLUtility.xmlInstance.deSerializeString(root, ModelPackage.COMBINEDFRAGMENT_INTERACTIONOPERATOR)));
		
		// references
		
		this.getOperand().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.COMBINEDFRAGMENT_OPERAND));
		
		this.getCfragmentGate().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.COMBINEDFRAGMENT_CFRAGMENTGATE));
		
		this.getFragment().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.INTERACTION_FRAGMENT));
	}
	
	public void dynamicSet(String featureID, Object value) {
		if(featureID == null || "".equals(featureID)) {
			return;
		}
		// attributes
		
		else if(ModelPackage.COMBINEDFRAGMENT_INTERACTIONOPERATOR.equals(featureID)) {
			interactionOperator = (InteractionOperator)value;
		}
		
		// references
		
		else
			super.dynamicSet(featureID, value);
	}
}
 
 
 
 
 